<!--
    pageSize: 每页显示的数量
    pageNumber : 当前第几页
    totalPage: 总页数
    totalRow: 总条数
-->

<template>
  <el-row type="flex" justify="end" class="block pdv15">
    <el-pagination
      :current-page="pageInfo.pageNumber"
      :page-sizes.sync="pageSizes"
      :page-size="pageInfo.pageSize"
      :total="pageInfo.totalRow"
      layout="total, sizes, prev, pager, next"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"/>
  </el-row>
</template>

<script>
import { scrollTo } from '@/utils/scrollTo'
export default {
  name: 'Pagination',
  props: {
    pageInfo: {
      type: Object
    },
    pageSizes: {
      type: Array,
      default: () => [20, 30, 50,100,200]
    },
    getTableList: {
      type: Function,
      default: null
    },
    onFilter: {
      type: Boolean,
      default: false
    },
    scrollTo: {
      type: Boolean,
      default: true
    },
    filter_info: {
      type: Object,
      default: () => { return {} }
    }
  },
  methods: {
    handleSizeChange(val) {
      this.$emit('handleSizeChange', val)
      this.pageInfo.pageSize = val
      this.getTableList && this.getTableList({ page: this.pageInfo.pageNumber, rows: this.pageInfo.pageSize }, this.pageInfo, );
      if (this.scrollTo) {
        scrollTo(0, 400)
      }
    },
    handleCurrentChange(val) {
      this.$emit('handleCurrentChange', val)
      this.pageInfo.pageNumber = val
      this.getTableList && this.getTableList({ page: this.pageInfo.pageNumber, rows: this.pageInfo.pageSize }, this.pageInfo)
      if (this.scrollTo) {
        scrollTo(0, 400)
      }
    }
  }
}
</script>

<style scoped>

</style>
